<?php
    class Submit_Model extends dl_connect{
        
        function __construct(){
            $this->Connect();
        }
        
        /**
         * Insert a record to sumit table
         * @return Int
         * */
        public function add($name, $email, $subject, $noidung, $ngayPost){
            $this->ExecuteSQL("INSERT INTO `dulich`.`submit` (`id` , `ten` , `email` , `chude` , `noidung` , `ngaypost`)
                                        VALUES (NULL , '{$name}', '{$email}', '{$subject}', '{$noidung}', '{$ngayPost}')");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        /**
         * edit a record from submit table
         * @return INT
         **/
        public function edit($name, $email, $subject, $noidung, $ngayPost, $id){
            $this->ExecuteSQL("UPDATE `dulich`.`submit` SET `ten` = '{$name}', `email` = '{$email}',
                                     `chude` = '{$subject}', `noidung` = '{$noidung}', `ngaypost` = '{$ngayPost}' 
                                     WHERE `submit`.`id` ={$id}");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        public function delete($id){
            $this->ExecuteSQL("DELETE FROM `dulich`.`submit` WHERE `submit`.`id` = {$id}");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
         
    }
?>